package main

import (
	"Demo03/part14/MyFuncGetIndex"
	"github.com/gin-gonic/gin"
	"net/http"
)

/*
路由分组，根据版本进行管理路由
*/
func main() {
	r := gin.Default()
	r.LoadHTMLGlob("part14/templates/**/*")

	r.StaticFS("/s", http.Dir("part14/static"))

	//根据版本去管理路由
	v1 := r.Group("version01")
	{
		v1.GET("/", MyFuncGetIndex.GetIndex)
		//form表单进行调用的地址
		v1.GET("/BandingForm", MyFuncGetIndex.BandingForm)

		//访问地址栏进行拼接
		//http://localhost:8080/BandingUrl?username=%E4%B8%BD%E4%B8%BD&age=123123
		v1.GET("/BandingUrl", MyFuncGetIndex.BandingUrl)
	}
	v2 := r.Group("version02")
	{
		//获取json绑定调用的首界面
		v2.GET("/getjsonindex", MyFuncGetIndex.JsonIndex)

		//处理ajax请求
		v2.POST("/postBanding", MyFuncGetIndex.AjaxJson)

		//绑定URI
		//http://localhost:8080/BandingUrI/张三/12

		v2.GET("/BandingUrI/:uname/:age", MyFuncGetIndex.GetBindUri)
	}

	r.Run()

}
